package com.work.work.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.nio.file.AccessDeniedException;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public R<String> handleException(Exception e) {
        if (e instanceof AccessDeniedException) {
            return R.fail("无权限访问");
        }
        return R.fail("服务器错误");
    }
}